package com.shsxt.controller;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alipay.api.AlipayApiException;
import com.shsxt.service.YuyueService;


@Controller
@RequestMapping("yuyue")
public class YuyueController  {
	
	/*1筛选上班中的阿姨
	 *2筛选阿姨的职能 
	 *3筛选阿姨的归属地
	 *4得到约满总数
	 *5比较约满总数和约满表 给用户显示约满时间表
	 *4预约成功 约满表各时间+1
	 */
	@Autowired
	private YuyueService yuyueService;
//月嫂的轮播提示
	@RequestMapping(value="ylunbo")
	public  @ResponseBody Map<String,Object> ylunbo() throws ParseException, UnsupportedEncodingException {
    	Map<String,Object> wode = yuyueService.ylunbo();
		return wode;
	}
	//日常保洁单，单次预约(地址，服务时长，保洁价格，预定时间，预定时间段，是否使用保洁剂，优惠券编号，手机号,订单类型)
	@RequestMapping(value="rdanci")
	public  @ResponseBody Map<String,Object> rDanci(String uuid, String serviceTime1,String orderTime,String timeSlot, String suppilies,String phoneNumber) throws ParseException, UnsupportedEncodingException {
    	Map<String,Object> wode = yuyueService.rdanci(uuid,  serviceTime1, orderTime, timeSlot, suppilies, phoneNumber );
		return wode;
	}
	//5种单次 单次预约(类型，地址，开荒类型，类型细节，预定时间，预定时间段，手机号)
	@RequestMapping(value="danci")
	public  @ResponseBody Map<String,Object> jDanci(String type,String uuid, String j_type,String typeDetail,String orderTime,String timeSlot,String phoneNumber) throws ParseException, UnsupportedEncodingException {
    	Map<String,Object> wode = yuyueService.jDanci(type,uuid, j_type, typeDetail, orderTime, timeSlot, phoneNumber );
		return wode;
	}
//月嫂单次预约(手机号,联系人,联系人性别,世实际手机号，预产月)
	@RequestMapping(value="ydanci")
		public  @ResponseBody Map<String,Object> ydanci(String uuid,String phoneNumber,String linkMan,String sex,String realPhoneNumber,String duedate) throws ParseException {
	    	Map<String,Object> wode = yuyueService.ydanci(uuid,phoneNumber, linkMan, sex, realPhoneNumber, duedate );
			return wode;
		}
//保姆单次预约(手机，地址，实际手机，需求【逗号分割】)
		@RequestMapping(value="bdanci")
		public  @ResponseBody Map<String,Object> bdanci(String phoneNumber,String uuid,String realPhoneNumber,String demand) throws ParseException {
	    	Map<String,Object> wode = yuyueService.bdanci( phoneNumber, uuid, realPhoneNumber, demand );
			return wode;
		}
	
	
	//进入预约 ,自动给默认地址
		@RequestMapping(value="giveAddress")
		public  @ResponseBody Map<String,Object> giveAddress(String phoneNumber) {
	    	Map<String,Object> wode = yuyueService.giveAddress(phoneNumber );
			return wode;
		}
	//5查询符合的优惠券
	@RequestMapping(value="usableCoupon")
	public  @ResponseBody Map<String,Object> usableCoupon(String phoneNumber,String orderNumber,String type) {
    	Map<String,Object> wode = yuyueService.usableCoupon(phoneNumber, orderNumber,type);
		return wode;
	}
	//6确定哪张优惠券
		@RequestMapping(value="chooseCoupon")
		public  @ResponseBody Map<String,Object> chooseCoupon(String redeemCode,String orderNumber,String type) {
	    	Map<String,Object> map = yuyueService.chooseCoupon(redeemCode, orderNumber,type);
			return map;
		}
		//不使用优惠券
		@RequestMapping(value="resetCoupon")
		public  @ResponseBody Map<String,Object> resetCoupon(String orderNumber,String type) {
	    	Map<String,Object> map = yuyueService.resetCoupon( orderNumber,type);
			return map;
		}

		
	//去支付
		@RequestMapping(value="toPay")
		public  @ResponseBody Map<String,Object> toPay(String orderNumber,String type ) throws ParseException {
	    	Map<String,Object> wode = yuyueService.toPay(orderNumber,type);
			return wode;
		}
  
	//获取单次预约约满表
		@RequestMapping(value="getYueMan")
		public  @ResponseBody Map<String,Object> getYueMan(String type,String day,String serviceTime,String uuid) throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException {
	    	Map<String,Object> wode = yuyueService.getYueMan(type,day,serviceTime,uuid);
			return wode;
		}
//日常保洁周期预约
		@RequestMapping(value="rcircle")
		public  @ResponseBody Map<String,Object> rcircle(String uuid,String serviceTime, String phoneNumber,String suppilies,String strdays,String weekTimes,String weeks) throws Exception {
	    	Map<String,Object> map = yuyueService.rcircle( uuid, serviceTime,  phoneNumber, suppilies, strdays, weekTimes, weeks);
			return map;
		}
/*//签名
		@RequestMapping(value="sign")
		public  @ResponseBody Map<String,Object> sign() throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException {
	    	Map<String,Object> map = yuyueService.sign();
			return map;
		}
		@RequestMapping(value="signyz")
		public  @ResponseBody String signyz() throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException {
	    	String map = yuyueService.signyz();
			return map;
		}*/
//签名
		@RequestMapping(value="newsign")
		public  @ResponseBody Map<String, Object> newsign(String orderNumber,String type,String redeemCode) throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException {
	    	Map<String, Object> map = yuyueService.newsign(orderNumber,type,redeemCode);
			return map;
		}
		@RequestMapping(value="yanzheng")
		public  @ResponseBody String yanzheng() throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException, AlipayApiException {
	    	String map = yuyueService.yanzheng();
			return map;
		}
		@RequestMapping(value="tuikuan")
		public  @ResponseBody  Map<String, Object> tuikuan(String out_trade_no,String refund_amount) throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException, AlipayApiException {
	    	Map<String, Object> map = yuyueService.alipayRefundRequest( out_trade_no, refund_amount);
			return map;
		}
		
		@RequestMapping(value="wxtuikuan")
		public  @ResponseBody  Map<String, String> wxtuikuan(HttpServletRequest request,HttpServletResponse response,String orderNumber,String total_fee) throws Exception {
	    	Map<String, String> map = yuyueService.wxtuikuan(  request, response, orderNumber, total_fee);
			return map;
		}
	
		@RequestMapping(value="getParam")
		public  @ResponseBody Map<String,Object> getParam() throws ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, UnsupportedEncodingException, AlipayApiException {
			Map<String,Object> map = yuyueService.getParam();
			return map;
		}
		
}
